package com.yeild.libs.rfid.android

import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.Result

class YeildLibsRfidAndroidPlugin: FlutterPlugin {
  companion object {
    private const val CHANNEL_NAME = "plugins.libs.yeild.com/rfid_android"
  }
  private var channel : MethodChannel? = null
  private var handler : MethodCallHandlerImpl? = null

  override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
    channel = MethodChannel(binding.binaryMessenger, CHANNEL_NAME)
    handler = MethodCallHandlerImpl(binding.applicationContext)
    channel?.setMethodCallHandler(handler)
  }

  override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
    handler?.teardown()
    handler = null
    channel?.setMethodCallHandler(null)
    channel = null
  }
}
